<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="ticket" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{ticketHome.managed ? 'Edit' : 'Add'} Ticket</f:facet>




            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{ticketHome.persist}"
                       disabled="#{!ticketHome.wired}"
                       rendered="#{!ticketHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{ticketHome.update}"
                       rendered="#{ticketHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{ticketHome.remove}"
                      immediate="true"
                       rendered="#{ticketHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Ticket.xhtml"
                rendered="#{ticketHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty ticketFrom ? 'TicketList' : ticketFrom}.xhtml"
                rendered="#{!ticketHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Reservation *" labelClass="required">
    <div class="association" id="reservationParent">

        <h:outputText value="There is no reservation associated with this ticket."
                   rendered="#{ticketHome.instance.reservation == null}"/>

        <rich:dataTable var="_reservation"
                   value="#{ticketHome.instance.reservation}"
                rendered="#{ticketHome.instance.reservation != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="reservationTable">
            <h:column>
                <f:facet name="header">Idreservation</f:facet>
                <h:outputText value="#{_reservation.idreservation}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Client idclient</f:facet>
                <h:outputText value="#{_reservation.client.idclient}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Voyage id voyage</f:facet>
                <h:outputText value="#{_reservation.voyage.idVoyage}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Date reservation</f:facet>
                <h:outputText value="#{_reservation.dateReservation}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{ticketHome.instance.reservation != null ? 'changeParentreservation' : 'selectParentreservation'}" value="#{ticketHome.instance.reservation != null ? 'Change' : 'Select'} reservation"
                       view="/ReservationList.xhtml">
                <f:param name="from" value="TicketEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Categorie *" labelClass="required">
    <div class="association" id="categorieParent">

        <h:outputText value="There is no categorie associated with this ticket."
                   rendered="#{ticketHome.instance.categorie == null}"/>

        <rich:dataTable var="_categorie"
                   value="#{ticketHome.instance.categorie}"
                rendered="#{ticketHome.instance.categorie != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="categorieTable">
            <h:column>
                <f:facet name="header">Idcategorie</f:facet>
                <h:outputText value="#{_categorie.idcategorie}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Libelle</f:facet>
                <h:outputText value="#{_categorie.libelle}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{ticketHome.instance.categorie != null ? 'changeParentcategorie' : 'selectParentcategorie'}" value="#{ticketHome.instance.categorie != null ? 'Change' : 'Select'} categorie"
                       view="/CategorieList.xhtml">
                <f:param name="from" value="TicketEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
